package C047;

import java.util.Arrays;

/**
 * ClassName: C01
 * Package: C047
 * Description:
 *
 * @Author BCXJ
 * @Create 2025/2/9 09:13
 * @Version 1.0
 * @Since 1.0
 */
public class C01 {
    public static void main(String[] args) {
        int[][] arr = {{1,2,10},{2,2,15}};
        System.out.println(Arrays.toString(corpFlightBookings(arr, 2)));
    }

    public static int[] corpFlightBookings(int[][] bookings, int n) {
        int[] ans = new int[n];
        for (int i = 0; i < bookings.length; i++) {
            ans[bookings[i][0] - 1] += bookings[i][2];
            if(bookings[i][1] < n) {
                ans[bookings[i][1]] -= bookings[i][2];
            }
        }
        int sum = 0;
        for (int i = 0; i < ans.length; i++) {
            sum += ans[i];
            ans[i] = sum;
        }
        return ans;
    }

}
